import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.FileFileFilter;
import org.apache.commons.io.filefilter.FileFilterUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.List;

public class RooUtils {
    private static String rootPath = "E:\\dev\\vw";
    //private static String[] extensions = {"java", "aj"};

    public static void main(String[] args) throws IOException {

        int lineNumber = 75;

        // 打样所有文件这一行.
        File file = new File(rootPath);
        printAllFile(lineNumber, file);
    }

    private static void printAllFile(final int lineNumber, File root) throws IOException {
        File[] files = root.listFiles();
        for (File file : files) {
            if (file.isFile()) {
                if ("java".equals(FilenameUtils.getExtension(file.getName()))) {
                    List<String> lines = IOUtils.readLines(new FileInputStream(file));
                    if (lines.size() < lineNumber) continue;
                    System.out.println(file.getName() + ":");
                    System.out.println(lines.get(lineNumber - 1));
                }
            } else {
                printAllFile(lineNumber, file);
            }
        }
    }
}
